import {Component, OnInit} from "@angular/core";
import {LoginService} from "../service/login.service";
import {Router} from "@angular/router";
@Component({
  selector: 'forget-pas-next',
  templateUrl: './forget_next.html',
})
export class ForgetNextPaswordComponent implements  OnInit{
  public flag:string;
  constructor(public loginservice:LoginService,public router:Router){}
  ngOnInit(): void {

  }
  public sendcode(){
    var verificationcode=  (<HTMLInputElement>document.getElementById("verification")).value;

    var email=sessionStorage.getItem("forgetEmail");
    this.loginservice.VarificationEmailCode(verificationcode,email);


  }

  public sendEmail(){
    var email=sessionStorage.getItem("forgetEmail");

    this.loginservice.SendEmailCode(email).then(flag=>this.flag=flag);
    clearInterval(timer); //清除计时器

    document.getElementById("sendEmail").setAttribute("disabled","false");

    var count = 60;
    var timer = setInterval(function(){
      if(count>0){
        count--;
        document.getElementById("sendEmail").innerHTML = "剩余时间"+ count +"s";
      }else{
        document.getElementById("sendEmail").innerHTML ="重新发送";
        document.getElementById("sendEmail").removeAttribute("disabled");
        clearInterval(timer); //清除计时器
      }
    },1000);
  }



}
